package run;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import platno.*;
import riadenie.*;

public class Graph extends Frame{

    static Platno pl;
    static RiadiaciDialog rd;
    static Parametre p;
    static Properties pr;
    
    Graph(){
        super.setTitle(getClass().getName());     
        pl = new Platno();
        rd = new RiadiaciDialog(this, false);
        p = new Parametre();
        pr = new Properties();
        pl.setSize(pr.getPlatnoSizeX(), pr.getPlatnoSizeY());        // Nastavy velkost platna.
        this.add(pl, BorderLayout.CENTER);

        this.setLayout(new FlowLayout());
        this.setSize(pr.getFrameSizeX(), pr.getFrameSizeY());        // Nastavy velkost okna typu Frame.
        
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {       
              System.exit(0);                                        // Zrusi cele okno typu Frame!
          }
        });  
        addWindowListener(new WindowAdapter() {
          public void windowDeiconified(WindowEvent e) {
        	  // implementovat co sa stane ak de-minimalizujem okno!
          }
        });
        addWindowListener(new WindowAdapter() {
            public void windowIconified(WindowEvent e) {
          	  // implementovat co sa stane ak minimalizujem okno!
            }
        });
    }

    public static void main(String[] args) {
   	  Graph graph = new Graph();
	  graph.setVisible(true);
      Kresli kr = new Kresli();
      kr.setPlRef(pl);                // Referencia objektu triedy Platno poslana -> do objektu triedy Kresli !
      kr.setPRef(p);                  // Referencia objektu triedy Parametre poslana -> do objektu triedy Kresli !
      rd.setPRef(p);                  // Referencia objektu triedy Parametre poslana -> do objektu triedy RiadiaciDialog ! 
      rd.setKrRef(kr);                // Referencia objektu triedy Kresli poslana -> do do objektu triedy RiadiaciDialog !
    //test mergu
      try{
         Thread.sleep(300);      
      }
      catch(InterruptedException e){      
         System.out.print("Hlavne vlakno prerusene !");      	
      }
      kr.maluj();

	}
}
